//
//  RootViewViewController.m
//  LoveDraw
//
//  Created by 梁晨 on 2017/6/13.
//  Copyright © 2017年 梁晨. All rights reserved.
//

#define studentTitle [UserInfoManage sharedInstance].userInfo.student_title
#define TeaCherTitle [UserInfoManage sharedInstance].userInfo.teacher_title;

#import "RootViewViewController.h"
#import "RootTableViewCell.h"
#import "MainViewController.h"
#import "SystemViewController.h"
#import "PopWindowView.h"
#import "MineWebViewController.h"

@interface RootViewViewController ()<UITableViewDelegate,UITableViewDataSource,UIImagePickerControllerDelegate,UINavigationControllerDelegate>

@property(nonatomic,strong)NSMutableArray *iconarr;
@property(nonatomic,strong)UIImageView *HeadUrlimageV;
@property(nonatomic,strong)UILabel *RealName;
@property(nonatomic,assign)NSInteger count;
@property(nonatomic,strong) NSString *isTeacher;
@property(nonatomic,strong)UIImagePickerController *pickerVC; // 照片选择器


@end

@implementation RootViewViewController



- (void)viewDidLoad
{
    [super viewDidLoad];

    // type是二的时候 既是老师 也是家长
    if([[[NSUserDefaults standardUserDefaults] objectForKey:Ktype] isEqualToString:@"2"])
    {
        self.isTeacher = @"2"; // 是老师界面
    }else
    {
        self.isTeacher = @"0"; // 完全不是老师
    }

    [self initBackGroundV];
    [self initHeadV];
    [self initBottomV];
    [self initTable];

    [[NSUserDefaults standardUserDefaults]setObject:@"1" forKey:@"NowType"];

}

-(NSMutableArray *)iconarr
{
    if (!_iconarr)
    {
         _iconarr = [@[[UIImage imageNamed:@"menu_01"],[UIImage imageNamed:@"menu_02"],[UIImage imageNamed:@"menu_03"],[UIImage imageNamed:@"menu_04"],[UIImage imageNamed:@"menu_05"],[UIImage imageNamed:@"menu_06"],[UIImage imageNamed:@"menu_07"],[UIImage imageNamed:@"menu_09"],[UIImage imageNamed:@"menu_08"],[UIImage imageNamed:@"menu_10"]] mutableCopy];
    }
    return _iconarr;
}

-(void)initBackGroundV
{
    self.view.backgroundColor = PKCOLOR(24, 33, 43);
}

-(void)initHeadV
{
    self.HeadUrlimageV= [[UIImageView alloc]init];
    self.HeadUrlimageV.layer.masksToBounds = YES;
    self.HeadUrlimageV.layer.cornerRadius = 50*KscreenW/375;
    [self.view addSubview:self.HeadUrlimageV];

    [self.HeadUrlimageV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",KUrl,[[NSUserDefaults standardUserDefaults]objectForKey:@"Head"]]] placeholderImage:nil];
    self.HeadUrlimageV.userInteractionEnabled = YES;
      UITapGestureRecognizer *selectTouXiangTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(selectImage)];
    [self.HeadUrlimageV addGestureRecognizer:selectTouXiangTap];

    self.RealName = [[UILabel alloc]init];
    self.RealName.text = [[NSUserDefaults standardUserDefaults]objectForKey:@"Name"];
    self.RealName.textColor = UIColors(0xCBC5C5);
    [self.view addSubview:self.RealName];

    [self.HeadUrlimageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(40*KscreenH/667);
        make.width.mas_equalTo(100*KscreenW/375);
        make.height.mas_equalTo(100*KscreenW/375);
        make.left.equalTo(self.view.mas_left).offset(40*KscreenW/375);
    }];

    [self.RealName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.HeadUrlimageV.mas_centerX);
        make.top.equalTo(self.HeadUrlimageV.mas_bottom).offset(10);
    }];
}

-(void)initBottomV
{
    UIImageView *imageV = [[UIImageView alloc]init];
    [self.view addSubview:imageV];
    imageV.image = [UIImage imageNamed:@"menu_set"];
    [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(20);
        make.bottom.equalTo(self.view.mas_bottom).offset(-10);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(40);
    }];

    UIButton *SetBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [SetBtn setTitle:@"系统设置" forState:(UIControlStateNormal)];
    SetBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [SetBtn setTitleColor:UIColors(0xCBC5C5) forState:(UIControlStateNormal)];
    [SetBtn addTarget:self action:@selector(SysSet) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:SetBtn];
    [SetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageV.mas_right).offset(10);
        make.centerY.equalTo(imageV.mas_centerY);
    }];
}

-(void)SysSet
{
    UIViewController *vc = [[NSClassFromString(@"SystemViewController")alloc]init];

    [_myNaviVC pushViewController:vc animated:YES];
    [_myNaviVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg"] forBarMetrics:(UIBarMetricsDefault)];
    [_myNaviVC.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];

    _myNaviVC.navigationBar.translucent = NO;

    [_myNaviVC setNavigationBarHidden:YES animated:YES];

    [self.view addSubview:_myNaviVC.view];

    CGRect newFrame = _myNaviVC.view.frame;

    newFrame.origin.x = kScreenWidth-kMoveDistance;

    _myNaviVC.view.frame = newFrame;

    [_rightVC ChangeFrameWithType:(MOVETYPELEFT)];
}

-(void)initTable
{
    if([self.isTeacher isEqualToString:@"2"])
    {
        //student_title
//teacher_title

        _controllers = @[@"MyClassViewController",@"LessonTeacherViewController",@"TeacherHoildayViewController",@"TeacherFeedBackViewController",@"MineShouRuViewController"];
        _titles = @[@"教学班级",@"课例管理",@"我的请假",@"投诉留言",@"我的收入",@"身份切换",[[NSUserDefaults standardUserDefaults]objectForKey:@"teacher_title"]];
        

        self.iconarr = [@[[UIImage imageNamed:@"menu_01"],[UIImage imageNamed:@"menu_02"],[UIImage imageNamed:@"menu_03"],[UIImage imageNamed:@"menu_07"],[UIImage imageNamed:@"menu_09"],[UIImage imageNamed:@"menu_08"],[UIImage imageNamed:@"menu_10"]] mutableCopy];

    }else if([self.isTeacher isEqualToString:@"1"])
    {
        _controllers = @[@"ChildViewController",@"LessonViewController",@"HoildayViewController",@"RecordViewController",@"LessonShareViewController",@"AdvViewController",@"FeedBackViewController"];
        _titles = @[@"我娃管理",@"课程管理",@"我的请假",@"上课记录",@"课例共享",@"校园公告",@"投诉留言",@"身份切换",[[NSUserDefaults standardUserDefaults]objectForKey:@"student_title"]];


          self.iconarr = [@[[UIImage imageNamed:@"menu_01"],[UIImage imageNamed:@"menu_02"],[UIImage imageNamed:@"menu_03"],[UIImage imageNamed:@"menu_04"],[UIImage imageNamed:@"menu_05"],[UIImage imageNamed:@"menu_06"],[UIImage imageNamed:@"menu_07"],[UIImage imageNamed:@"menu_08"],[UIImage imageNamed:@"menu_10"]] mutableCopy];
    }else
    {
        _controllers = @[@"ChildViewController",@"LessonViewController",@"HoildayViewController",@"RecordViewController",@"LessonShareViewController",@"AdvViewController",@"FeedBackViewController"];
        _titles = @[@"我娃管理",@"课程管理",@"我的请假",@"上课记录",@"课例共享",@"校园公告",@"投诉留言",[[NSUserDefaults standardUserDefaults]objectForKey:@"student_title"]];

      self.iconarr = [@[[UIImage imageNamed:@"menu_01"],[UIImage imageNamed:@"menu_02"],[UIImage imageNamed:@"menu_03"],[UIImage imageNamed:@"menu_04"],[UIImage imageNamed:@"menu_05"],[UIImage imageNamed:@"menu_06"],[UIImage imageNamed:@"menu_07"],[UIImage imageNamed:@"menu_08"],[UIImage imageNamed:@"menu_10"]] mutableCopy];
    }

     UITableView *table = [[UITableView alloc]initWithFrame:CGRectMake(0, 200*KscreenH/667,180 *KscreenW/375,KscreenH-150*KscreenH/667-200*KscreenH/667) style:(UITableViewStylePlain)];
    table.estimatedSectionFooterHeight = 0;
    table.estimatedSectionHeaderHeight = 0;
    table.tag = 1000;
    table.backgroundColor = UIColors(0x19212B);
    table.delegate = self;
    table.dataSource = self;
    [table registerClass:[UITableViewCell class] forCellReuseIdentifier:@"rootCell"];
    table.rowHeight = 40;
    table.scrollEnabled = NO;
    table.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:table];
    [table selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
    [table registerNib:[UINib nibWithNibName:@"RootTableViewCell" bundle:nil] forCellReuseIdentifier:@"RootTableViewCell"];
    
    _rightVC = [[MainViewController alloc]init];
    _myNaviVC = [[MyNavigation alloc]initWithRootViewController:_rightVC];
    [_myNaviVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg"] forBarMetrics:(UIBarMetricsDefault)];
    [_myNaviVC.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    _myNaviVC.navigationBar.translucent = NO;
    _myNaviVC.navigationBar.hidden = YES;
     _myNaviVC.interactivePopGestureRecognizer.delegate = (id)self;
    [self addChildViewController:_myNaviVC];
    [self.view addSubview:_myNaviVC.view];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"%ld",_titles.count);

    return _titles.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    RootTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RootTableViewCell" forIndexPath:indexPath];
    
    cell.TitleImageV.image =self.iconarr[indexPath.row];
    
    cell.TitleL.text = self.titles[indexPath.row];

    NSLog(@"%@",self.titles[indexPath.row]);

    cell.selectionStyle = 0;

    cell.backgroundColor = [UIColor clearColor];

    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *title = self.titles[indexPath.row];
    if ([title isEqualToString:[[NSUserDefaults standardUserDefaults]objectForKey:@"student_title"]])
    {
        MineWebViewController *vc = [[MineWebViewController alloc]init];
        vc.url = @"/index.php?g=App&m=Index&a=serviceH5&sid=2";
        vc.title = self.titles[indexPath.row];
        [_myNaviVC pushViewController:vc animated:YES];
        [_myNaviVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg"] forBarMetrics:(UIBarMetricsDefault)];
        [_myNaviVC.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
        _myNaviVC.navigationBar.translucent = NO;
        [_myNaviVC setNavigationBarHidden:YES animated:YES];
        [self.view addSubview:_myNaviVC.view];
        CGRect newFrame = _myNaviVC.view.frame;
        newFrame.origin.x = kScreenWidth-kMoveDistance;
        _myNaviVC.view.frame = newFrame;
        [_rightVC ChangeFrameWithType:(MOVETYPELEFT)];
    }else if ([title isEqualToString:[[NSUserDefaults standardUserDefaults]objectForKey:@"teacher_title"]])
    {
        MineWebViewController *vc = [[MineWebViewController alloc]init];
        vc.url = @"/index.php?g=App&m=Index&a=serviceH5&sid=1";
        vc.title = self.titles[indexPath.row];
        [_myNaviVC pushViewController:vc animated:YES];
        [_myNaviVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg"] forBarMetrics:(UIBarMetricsDefault)];
        [_myNaviVC.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];

        _myNaviVC.navigationBar.translucent = NO;

        [_myNaviVC setNavigationBarHidden:YES animated:YES];

        [self.view addSubview:_myNaviVC.view];

        CGRect newFrame = _myNaviVC.view.frame;

        newFrame.origin.x = kScreenWidth-kMoveDistance;

        _myNaviVC.view.frame = newFrame;

        [_rightVC ChangeFrameWithType:(MOVETYPELEFT)];
    }else
    {
        if ([self.isTeacher isEqualToString:@"1"]) {
            if (indexPath.row<7) {
                if ([_rightVC isMemberOfClass:[NSClassFromString(_controllers[indexPath.row])class]]) {
                    [_rightVC ChangeFrameWithType:MOVETYPELEFT];
                    return;
                }
                UIViewController *vc = [[NSClassFromString(_controllers[indexPath.row])alloc]init];
                [_myNaviVC pushViewController:vc animated:YES];

                [_myNaviVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg"] forBarMetrics:(UIBarMetricsDefault)];
                [_myNaviVC.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];

                _myNaviVC.navigationBar.translucent = NO;

                [_myNaviVC setNavigationBarHidden:YES animated:YES];

                [self.view addSubview:_myNaviVC.view];

                CGRect newFrame = _myNaviVC.view.frame;

                newFrame.origin.x = kScreenWidth-kMoveDistance;

                _myNaviVC.view.frame = newFrame;

                [_rightVC ChangeFrameWithType:(MOVETYPELEFT)];
            }else
            {
                if ([self.isTeacher isEqualToString:@"1"])
                {

                    self.isTeacher = @"2";
                    _controllers = @[@"MyClassViewController",@"LessonTeacherViewController",@"TeacherHoildayViewController",@"TeacherFeedBackViewController",@"MineShouRuViewController"];
                    _titles = @[@"教学班级",@"课例管理",@"我的请假",@"投诉留言",@"我的收入",@"身份切换",[[NSUserDefaults standardUserDefaults]objectForKey:@"teacher_title"]];
                    self.iconarr = [@[[UIImage imageNamed:@"menu_01"],[UIImage imageNamed:@"menu_02"],[UIImage imageNamed:@"menu_03"],[UIImage imageNamed:@"menu_07"],[UIImage imageNamed:@"menu_09"],[UIImage imageNamed:@"menu_08"],[UIImage imageNamed:@"menu_10"]] mutableCopy];
                    [self MainViewSwitchingData:@"2"];
                }else
                {

                    self.isTeacher = @"1";
                    _controllers = @[@"ChildViewController",@"LessonViewController",@"HoildayViewController",@"RecordViewController",@"LessonShareViewController",@"AdvViewController",@"FeedBackViewController"];
                    _titles = @[@"我娃管理",@"课程管理",@"我的请假",@"上课记录",@"课例共享",@"校园公告",@"投诉留言",@"身份切换",[[NSUserDefaults standardUserDefaults]objectForKey:@"student_title"]];
                    self.iconarr = [@[[UIImage imageNamed:@"menu_01"],[UIImage imageNamed:@"menu_02"],[UIImage imageNamed:@"menu_03"],[UIImage imageNamed:@"menu_04"],[UIImage imageNamed:@"menu_05"],[UIImage imageNamed:@"menu_06"],[UIImage imageNamed:@"menu_07"],[UIImage imageNamed:@"menu_08"],[UIImage imageNamed:@"menu_10"]] mutableCopy];
                    [self MainViewSwitchingData:@"1"];
                }
                UITableView *tabV = [self.view viewWithTag:1000];
                tabV.rowHeight = 40;
                [tabV reloadData];
            }
        }else if([self.isTeacher isEqualToString:@"2"])
        {
            if (indexPath.row == 5)
            {
                if ([self.isTeacher isEqualToString:@"1"])
                {
                    self.isTeacher = @"2";
                    _controllers = @[@"MyClassViewController",@"LessonTeacherViewController",@"TeacherHoildayViewController",@"TeacherFeedBackViewController",@"MineShouRuViewController"];
                    _titles = @[@"教学班级",@"课例管理",@"我的请假",@"投诉留言",@"我的收入",@"身份切换",[[NSUserDefaults standardUserDefaults]objectForKey:@"teacher_title"]];
                    self.iconarr = [@[[UIImage imageNamed:@"menu_01"],[UIImage imageNamed:@"menu_02"],[UIImage imageNamed:@"menu_03"],[UIImage imageNamed:@"menu_07"],[UIImage imageNamed:@"menu_09"],[UIImage imageNamed:@"menu_08"],[UIImage imageNamed:@"menu_10"]] mutableCopy];
                    [self MainViewSwitchingData:@"2"];
                }else
                {

                    self.isTeacher = @"1";
                    _controllers = @[@"ChildViewController",@"LessonViewController",@"HoildayViewController",@"RecordViewController",@"LessonShareViewController",@"AdvViewController",@"FeedBackViewController"];

                    NSString *student = [[NSUserDefaults standardUserDefaults]objectForKey:@"student_title"];


                    _titles = @[@"我娃管理",@"课程管理",@"我的请假",@"上课记录",@"课例共享",@"校园公告",@"投诉留言",@"身份切换",student];

                    self.iconarr = [@[[UIImage imageNamed:@"menu_01"],[UIImage imageNamed:@"menu_02"],[UIImage imageNamed:@"menu_03"],[UIImage imageNamed:@"menu_04"],[UIImage imageNamed:@"menu_05"],[UIImage imageNamed:@"menu_06"],[UIImage imageNamed:@"menu_07"],[UIImage imageNamed:@"menu_08"],[UIImage imageNamed:@"menu_10"]] mutableCopy];





                    [self MainViewSwitchingData:@"1"];
                }
                UITableView *tabV = [self.view viewWithTag:1000];
                tabV.rowHeight = 40;
                [tabV reloadData];

            }else
            {
                if ([_rightVC isMemberOfClass:[NSClassFromString(_controllers[indexPath.row])class]]) {
                    [_rightVC ChangeFrameWithType:MOVETYPELEFT];
                    return;
                }
                UIViewController *vc = [[NSClassFromString(_controllers[indexPath.row])alloc]init];
                [_myNaviVC pushViewController:vc animated:YES];
                [_myNaviVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg"] forBarMetrics:(UIBarMetricsDefault)];
                [_myNaviVC.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
                _myNaviVC.navigationBar.translucent = NO;
                [_myNaviVC setNavigationBarHidden:YES animated:YES];
                [self.view addSubview:_myNaviVC.view];
                CGRect newFrame = _myNaviVC.view.frame;
                newFrame.origin.x = kScreenWidth-kMoveDistance;
                _myNaviVC.view.frame = newFrame;
                [_rightVC ChangeFrameWithType:(MOVETYPELEFT)];
            }
        }else if ([self.isTeacher isEqualToString:@"0"])
        {
            if ([_rightVC isMemberOfClass:[NSClassFromString(_controllers[indexPath.row])class]]) {
                [_rightVC ChangeFrameWithType:MOVETYPELEFT];
                return;
            }
            UIViewController *vc = [[NSClassFromString(_controllers[indexPath.row])alloc]init];
            [_myNaviVC pushViewController:vc animated:YES];
            [_myNaviVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg"] forBarMetrics:(UIBarMetricsDefault)];
            [_myNaviVC.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
            _myNaviVC.navigationBar.translucent = NO;
            [_myNaviVC setNavigationBarHidden:YES animated:YES];
            [self.view addSubview:_myNaviVC.view];
            CGRect newFrame = _myNaviVC.view.frame;
            newFrame.origin.x = kScreenWidth-kMoveDistance;
            _myNaviVC.view.frame = newFrame;
            [_rightVC ChangeFrameWithType:(MOVETYPELEFT)];
        }
    }
}


-(void)MainViewSwitchingData:(NSString *)isTeacher
{
    MainViewController *mainV = [self.myNaviVC.viewControllers firstObject];

    if ([isTeacher isEqualToString:@"1"]) {
        //不是老师
        [mainV ReloadDada:@"2"];
    }else
    {
        // 是老师
        [mainV ReloadDada:@"1"];
    }
}

#pragma mark --- 上传照片的代码
-(void)selectImage
{
    UIAlertController *imagechangeAc = [UIAlertController alertControllerWithTitle:@"更改头像" message:nil preferredStyle:(UIAlertControllerStyleActionSheet)];
    UIAlertAction *album = [UIAlertAction actionWithTitle:@"从手机相册选择" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action)
    {
        self.pickerVC = [[UIImagePickerController alloc]init];
        self.pickerVC.delegate = self;
        self.pickerVC.allowsEditing = YES;
        self.pickerVC.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        self.pickerVC.navigationBar.barTintColor = UIColors(0xF4760E);
        [self presentViewController:self.pickerVC animated:YES completion:nil];
    }];

    UIAlertAction *takePhoto = [UIAlertAction actionWithTitle:@"打开相机拍一张" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        self.pickerVC = [[UIImagePickerController alloc]init];
        self.pickerVC.delegate = self;
        self.pickerVC.allowsEditing = YES;
        self.pickerVC.sourceType = UIImagePickerControllerSourceTypeCamera;
        self.pickerVC.navigationBar.barTintColor = UIColors(0xF4760E);
        [self presentViewController:self.pickerVC animated:YES completion:nil];
    }];

    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleDefault) handler:nil];
    [imagechangeAc addAction:album];
    [imagechangeAc addAction:takePhoto];
    [imagechangeAc addAction:cancel];
    [self presentViewController:imagechangeAc animated:YES completion:nil];
    
}


-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
    UIImage *image = info[@"UIImagePickerControllerEditedImage"];
    [[UploadImage sharedClient]doUploadImage:@"/index.php?g=App&m=Index&a=uploadsImgone" parameters:@{@"uid":[[NSUserDefaults standardUserDefaults]objectForKey:kUserId],@"access_token":[[NSUserDefaults standardUserDefaults]objectForKey:kAccessToken]} image:image successBlock:^(id responseBody)
     {
         NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:responseBody options:0 error:nil];
         [HUD showText:jsonDic[@"msg"] AfterTime:1];
         if ([jsonDic[@"flag"]isEqualToString:@"Success"])
         {
             self.HeadUrlimageV.image = info[@"UIImagePickerControllerEditedImage"];
             [self uiloadHeadUrl:jsonDic[@"data"]];
         }
     } failureBlock:^(NSString *error)
     {

     }];
    [picker dismissViewControllerAnimated:YES completion:nil];
}

-(void)uiloadHeadUrl:(NSString *)url
{
    [RequestManager HudRequestWithUrl:@"/index.php?g=App&m=Index&a=editHeadimg" parmDic:@{@"imgurl":url} requestType:RequestPOST view:self.view Success:^(id data)
    {

    } error:^(NSError *error) {

    }];
}


-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//    cell.textLabel.textColor = PKCOLOR(80, 80, 80);

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
